﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_func_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ctp_lib.check_login(this.Page, "~/admin/func/manager_login.aspx", false);

        if (!IsPostBack)
        {

            ctpDataContext db = new ctpDataContext();

            if (db.ct_profiles.Count(p => p.manager_user_no == (int)Session["userno"] && p.manager_user_no != null) != 0)
            {
                this.txtMsg.Text = "管理者";
                this.Panel2.Visible = true;

                this.ManagerMsg.Text = db.users.Single(p => p.no == (int)Session["userno"]).nickname.Trim() + ", 您好";

                if ((int)Session["userno"] == 9)
                {
                    var data = from p in db.ct_profiles
                               select new
                               {
                                   country = p.country,
                                   city = p.title,
                                   url = "~/admin/func/city_m.aspx?no=" + p.no,

                                                                  };

                    this.GridView3.DataSource = data;
                    this.GridView3.DataBind();
                }
                else
                {
                    var data = from p in db.ct_profiles
                               where p.manager_user_no == (int)Session["userno"]
                               select new
                               {
                                   country = p.country,
                                   city = p.title,
                                   url = "~/admin/func/city_m.aspx?no=" + p.no
                               };

                    this.GridView3.DataSource = data;
                    this.GridView3.DataBind();
                }
            }
            else
            {
                this.txtMsg.Text = "不是管理者";
                this.Panel2.Visible = false;
            }
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }
}
